package com.example.aircraftwar2024.music;

import android.content.Context;
import android.media.MediaPlayer;

import com.example.aircraftwar2024.R;

import java.security.cert.TrustAnchor;

public class MyMediaPlayer {
    private MediaPlayer normal_bgm;
    private int position;
    private MediaPlayer boss_bgm;
    public MyMediaPlayer(Context context){
        super();
        normal_bgm = MediaPlayer.create(context, R.raw.bgm);
        boss_bgm = MediaPlayer.create(context, R.raw.bgm_boss);
        position = normal_bgm.getCurrentPosition();
        normal_bgm.setLooping(true);
        boss_bgm.setLooping(true);
    }
    public void playNormalBgm(){
        normal_bgm.seekTo(position);
        normal_bgm.start();
    }
    public void pauseNormalBgm(){
        normal_bgm.pause();
        position = normal_bgm.getCurrentPosition();
    }
    public void playBossBgm(){
        boss_bgm.seekTo(0);
        boss_bgm.start();
    }
    public void pauseBossBgm(){ boss_bgm.pause();}
    public void terminate(){
        normal_bgm.stop();
        boss_bgm.stop();
        normal_bgm.release();
        boss_bgm.release();
        normal_bgm = null;
        boss_bgm = null;
    }
}
